package com.hellenic.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.hibernate.SessionFactory;

import com.hellenic.beans.ProprieteBean;
import com.hellenic.mod.ProprieteMod;

@SuppressWarnings( "serial" )
public class Propriete extends HttpServlet {
    private static final String VUE              = "/WEB-INF/bien.jsp";
    private static final String ATTR_DAO_FACTORY = "sessionF";
    private ProprieteMod           proprieteM;

    public void init() {
        SessionFactory sf = (SessionFactory) getServletContext().getAttribute( ATTR_DAO_FACTORY );
        proprieteM = new ProprieteMod( sf );
        System.out.println( "Message : Initialisation servlet Propriete" );
    }

    public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
        ProprieteBean unePropriete = proprieteM.getPropriete( request );
        request.setAttribute( "unePropriete", unePropriete );
        this.getServletContext().getRequestDispatcher( VUE ).forward( request, response );
    }
}
